from PySide6.QtWidgets import QFrame, QVBoxLayout, QLabel
from PySide6.QtCore import Qt
from PySide6.QtGui import QFont


class GlassFrame(QFrame):
    """玻璃效果框架"""

    def __init__(self, parent=None):
        super().__init__(parent)
        self.setStyleSheet("""
            QFrame {
                background: rgba(255, 255, 255, 0.9);
                border: 1px solid rgba(200, 200, 200, 0.5);
                border-radius: 12px;
                margin: 5px;
            }
        """)


class StatItem(QFrame):
    """统计项组件"""

    def __init__(self, value, label, parent=None):
        super().__init__(parent)
        self.setup_ui(value, label)

    def setup_ui(self, value, label):
        self.setStyleSheet("""
            StatItem {
                background: rgba(52, 152, 219, 0.1);
                border: 1px solid rgba(52, 152, 219, 0.3);
                border-radius: 8px;
                padding: 10px;
                margin: 2px;
            }
        """)

        layout = QVBoxLayout(self)
        layout.setAlignment(Qt.AlignmentFlag.AlignCenter)
        layout.setSpacing(5)

        # 数值标签
        self.value_label = QLabel(value)
        self.value_label.setFont(QFont("Microsoft YaHei", 16, QFont.Weight.Bold))
        self.value_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
        self.value_label.setStyleSheet("color: #2980b9; font-weight: bold;")

        # 描述标签
        desc_label = QLabel(label)
        desc_label.setFont(QFont("Microsoft YaHei", 10))
        desc_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
        desc_label.setStyleSheet("color: #34495e;")

        layout.addWidget(self.value_label)
        layout.addWidget(desc_label)
